<template>
  <div
    class="box"
    :style="{
      height: overLine ? 'auto' : '48px',
    }"
  >
    <div class="labels" id="labels">
      <div
        v-for="(item, index) in labelData"
        :key="index"
        class="tag"
        :style="{
          color: item.color && item.color !== '#FFFFFF' ? '#FFFFFF' : '#999',
          background: item.color ? item.color : '#FFFFFF',
          border:
            item.color === '#FFFFFF' || !item.color ? '1px solid #999' : 'none',
        }"
      >
        {{ call ? item.fullName : item.name }}
      </div>
      <span v-if="labelsHeight > 80" class="icon" @click="afoldFun"
        ><i
          class="V7_iconfont"
          style="color: #a6a6ae"
          :class="
            overLine
              ? 'V7_iconV7tubiao_jiantoushang'
              : 'V7_iconV7tubiao_jiantouxia'
          "
        ></i
      ></span>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
@Component({
  name: 'Label'
})
export default class LabelDropdown extends Vue {
  @Prop() private labelData
  @Prop({ default: false }) private call

  private overLine: boolean = false

  private labelsHeight: any = ''

  private tags = [
    {
      name: 'dasd',
      color: '#999'
    },
    {
      name: 'dasd312124234',
      color: '#999'
    },
    {
      name: 'dasd421341',
      color: '#999'
    },
    {
      name: 'dasd',
      color: '#999'
    },
    {
      name: 'dasd312124234',
      color: '#999'
    },
    {
      name: 'dasd421341',
      color: '#999'
    },
    {
      name: 'dasd',
      color: '#999'
    },
    {
      name: 'dasd312124234',
      color: '#999'
    },
    {
      name: 'dasd421341',
      color: '#999'
    },
    {
      name: 'dasd',
      color: '#999'
    },
    {
      name: 'dasd312124234',
      color: '#999'
    },
    {
      name: 'dasd421341',
      color: '#999'
    }
  ]

  private afoldFun () {
    this.overLine = !this.overLine
  }

  private mounted () {
    this.labelsHeight = document.getElementById('labels')?.offsetHeight
  }
}
</script>
<style lang="stylus" scoped>
.box
  overflow hidden
  border-bottom 1px solid #ECF0F3
.labels
  height auto
  padding 12px 0 2px
  position relative
.tag
  display inline-block
  padding 5px 10px
  border-radius 12px
  margin 0 10px 13px 0
.icon
  display inline-block
  cursor pointer
  width 16px
  height 16px
  margin-left 10px
  border 1px solid #E7E9ED
  border-radius 50%
  position absolute
  top 12px
  right 0
</style>
